﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CreateRoomOneTimesBetPage : EventManager
{
    public override void InformationSetting()
    {
        OneTimesBet = "10";

        AddListenerToButton(confirmBtn, ConfirmBtnClick);
        AddListenerToButton(cancelBtn, CancelBtnClick);

        TimeSliderSelect(0);
    }

    public UnityEngine.UI.Button confirmBtn;
    public Button cancelBtn;
    public Slider OneTimesBetSlider;
    public GameObject numGroup;

    private string OneTimesBet;
    public void OneTimesBetSliderValueChange()
    {
        int temp = Mathf.FloorToInt(OneTimesBetSlider.value / 0.5f);
        OneTimesBetSlider.value = temp * 0.5f;
        GetOneTimesBet(temp.ToString());
        TimeSliderSelect(temp);
    }

    private void TimeSliderSelect(int num)
    {
        for (int i = 0; i < 3; i++)
        {
            if (i == num)
            {
                numGroup.transform.GetChild(i).gameObject.SetActive(true);
            }
            else
            {
                numGroup.transform.GetChild(i).gameObject.SetActive(false);
            }
        }

        for (int i = 3; i < 6; i++)
        {
            if (i == num+3)
            {
                numGroup.transform.GetChild(i).gameObject.SetActive(false);
            }
            else
            {
                numGroup.transform.GetChild(i).gameObject.SetActive(true);
            }
        }
    }

    private void GetOneTimesBet(string str)
    {
        switch (str)
        {
            case "0":
                OneTimesBet = "10";
                break;
            case "1":
                OneTimesBet = "15";
                break;
            case "2":
                OneTimesBet = "20";
                break;
        }
    }

    public void ConfirmBtnClick()
    {
        CreateRoomController.GetInstance().OneTimesBet = OneTimesBet;
        CreateRoomPage.GetInstance().oneTimesBet = 100;
         CreateRoomPage.GetInstance().GetAndSetServiceCharge();
        CloseBtnClick();
    }

    public void CancelBtnClick()
    {
        CreateRoomPage.GetInstance().SetToggleIsOff(5);
        CloseBtnClick();
    }
}
